{extend name="public/base"/}
{block name="style"}
<script type="text/javascript">
	//调用微信JS api 支付
	function onBridgeReady(){
	   WeixinJSBridge.invoke(
		   'getBrandWCPayRequest', {$jsApiParameters},
		   function(res){     
				//WeixinJSBridge.log(res.err_msg);
				//alert(res.err_code+res.err_desc+res.err_msg);
				
				if(/ok$/i.test(res.err_msg)){
					//alert('支付成功，实际到账请稍候！');
					window.location.href = '{$referer}';
				}else{
					//alert('对不起，支付失败！');
					window.location.href = '{$payErrorUrl}';
				}
		   }
	   ); 
	}
	if (typeof WeixinJSBridge == "undefined"){
	   if( document.addEventListener ){
		   document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
	   }else if (document.attachEvent){
		   document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
		   document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
	   }
	}else{
	   onBridgeReady();
	}
</script>
{/block}
